<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2019/5/10
 * Time: 16:32
 */
header("Content-Type:application/json;charset=utf-8");
header("Access-Control-Allow-Origin:*");
include "dbhealper.php";
session_start();

if($_SERVER["REQUEST_METHOD"]=="POST"){
    $UNAME=$_POST["uname"];
    $UPWD=$_POST["upwdo"];

    $sql="select `u_id`,`u_name` from `userinfo` where `u_name`='".$UNAME."' and `u_pwd`='".$UPWD."'";

    $result=dbhealper($sql);

    if($result->num_rows>=1){
        $users=$result->fetch_assoc();
        $arr=Array("msg"=>"登陆成功","status"=>"1","data"=>$users);
        print_r(json_encode($arr));
        $_SESSION["userinfo"]=$users;

    }else{
        $arr=Array("msg"=>"用户名或密码错误","status"=>"-1");
        print_r(json_encode($arr));
}

}else{
    $arr=Array("msg"=>"不支持get请求方式","status"=>"0");
    print_r(json_encode($arr));
}